package com.itlong.cloud.app.resource;

import com.itlong.cloud.POJO.DTO.app.AppGetVisitPassWordDTO;
import com.itlong.cloud.POJO.DTO.app.AppGetVisitorRecordPageDTO;
import com.itlong.cloud.POJO.DTO.app.MiniGetReservationProofPageDTO;
import com.itlong.cloud.POJO.PO.AppVisitorPassCodeRecordPO;
import com.itlong.cloud.POJO.VO.app.AppGetVisitorRecordPageVO;
import com.itlong.cloud.POJO.VO.app.MiniGetReservationProofPageVO;
import com.itlong.cloud.POJO.VO.app.MiniGetVisitorPassRecordPageVO;
import com.itlong.cloud.app.service.IAppVisitorPassCodeRecordService;
import com.itlong.cloud.equip.app.IAppVisitorPassCodeRecordServiceClient;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      访客密码通行记录业务处理暴露接口实现类
 * </desc>
 *
 * @createDate 2017/10/30
 */
@RestController
public class AppVisitorPassCodeRecordServiceResource implements IAppVisitorPassCodeRecordServiceClient{
    @Autowired
    IAppVisitorPassCodeRecordService iAppVisitorPassCodeRecordService;

    /**
     * <desc>
     *      保存访客密码通行记录
     * </desc>
     *
     * @param appGetVisitPassWordDTO 密码通行记录实体类
     * @return sql执行行数
     * @author Jiaqi.X
     * @createDate 2017/10/30
     */
    @RequestMapping(path = "/app/visitor/save",method = RequestMethod.POST)
    @Override
    public AppVisitorPassCodeRecordPO save(@RequestBody AppGetVisitPassWordDTO appGetVisitPassWordDTO) throws Exception{
        return iAppVisitorPassCodeRecordService.save(appGetVisitPassWordDTO);
    }

    /**
     * <desc>
     *      保存访客人脸信息
     * </desc>
     *
     * @param passId 访客信息编号
     * @param uploadFilePath 图片地址
     * @param vFaceId 百度中的人脸编号
     * @param projectId 项目编号
     * @param idcardKey 身份证序号
     * @param idcardKey 访客预约标识
     * @return sql执行行数
     * @author Qiang.S
     * @createDate 2019/02/27
     */
    @RequestMapping(path = "/app/visitor/setVisitPassFace",method = RequestMethod.POST)
    @Override
    public Integer setVisitPassFace(@RequestParam("passId")String passId, @RequestParam("uploadFilePath")String uploadFilePath,
                                    @RequestParam("vFaceId")String vFaceId, @RequestParam("projectId")String projectId,
                                    @RequestParam("idcardKey")String idcardKey, @RequestParam("visitorReservationMark")Integer visitorReservationMark) throws Exception{
        return iAppVisitorPassCodeRecordService.setVisitPassFace(passId,uploadFilePath,vFaceId,projectId,idcardKey,visitorReservationMark);
    }

    /**
     * <desc>
     *      获取分页数据
     * </desc>
     *
     * @param pageDTO   参数DTO
     * @return
     * @author Jiaqi.X
     * @createDate 2017/10/31
     */
    @RequestMapping(path = "/app/visitor/getVisitorRecord",method = RequestMethod.POST)
    @Override
    public Page<AppGetVisitorRecordPageVO> getPage(@RequestBody AppGetVisitorRecordPageDTO pageDTO) throws Exception{
        return iAppVisitorPassCodeRecordService.getPage(pageDTO);
    }

    /**
     * <desc>
     *      设置已分享
     * </desc>
     *
     * @param passId   访客唯一编号
     * @return
     * @author Qiang.S
     * @createDate 2019/04/16
     */
    @RequestMapping(path = "/app/visitor/setShare",method = RequestMethod.POST)
    @Override
    public void setShare(@RequestParam("passId")String passId) throws Exception{
        iAppVisitorPassCodeRecordService.setShare(passId);
    }

    /**
     * <desc>
     *      根据楼栋,单元,房间查询地址
     * </desc>
     *
     * @param buildId   楼栋编号
     * @param unitId   单元编号
     * @param roomId   房间编号
     * @return
     * @author Qiang.S
     * @createDate 2019/04/16
     */
    @RequestMapping(path = "/app/visitor/getAddress",method = RequestMethod.POST)
    @Override
    public String getAddress(@RequestParam("buildId")String buildId, @RequestParam("unitId")String unitId, @RequestParam("roomId")String roomId) throws Exception{
        return iAppVisitorPassCodeRecordService.getAddress(buildId,unitId,roomId);
    }

    /**
     * <desc>
     *      根据访客编号获取信息
     * </desc>
     *
     * @param passId 访客编号
     * @return 格式化响应结果
     * @author Qiang.S
     * @createDate 2019/04/24
     */
    @RequestMapping(path = "/app/visitor/getVisitorPassByPassId",method = RequestMethod.POST)
    @Override
    public AppGetVisitorRecordPageVO getVisitorPassByPassId(@RequestParam("passId")String passId) throws Exception{
        return iAppVisitorPassCodeRecordService.getVisitorPassByPassId(passId);
    }

    /**
     * <desc>
     *      删除访客信息
     * </desc>
     *
     * @param passId 访客编号
     * @return 格式化响应结果
     * @author Qiang.S
     * @createDate 2019/04/28
     */
    @RequestMapping(path = "/app/visitor/deleteVisitorInfo",method = RequestMethod.POST)
    @Override
    public Integer deleteVisitorInfo(@RequestParam("passId")String passId) throws Exception {
        return iAppVisitorPassCodeRecordService.deleteVisitorInfo(passId);
    }

     /**
     * <desc>
     *      获取访客预约凭证分页数据
     * </desc>
     *
     * @param pageDTO   参数DTO
     * @return
     * @author Juguang.S
     * @createDate 2019/04/29
     */
    @Override
    @RequestMapping(path = "/app/visitor/getReservationProofPage",method = RequestMethod.POST)
    public Page<MiniGetReservationProofPageVO> getReservationProofPage(@RequestBody MiniGetReservationProofPageDTO pageDTO) throws Exception {
        return iAppVisitorPassCodeRecordService.getReservationProofPage(pageDTO);
    }

    /**
     * <desc>
     *      获取访客身份通行记录
     * </desc>
     *
     * @param pageDTO   参数DTO
     * @return
     * @author Juguang.S
     * @createDate 2019/04/30
     */
    @Override
    @RequestMapping(path = "/app/visitor/getVisitorPassRecordPage",method = RequestMethod.POST)
    public Page<MiniGetVisitorPassRecordPageVO> getVisitorPassRecordPage(@RequestBody MiniGetReservationProofPageDTO pageDTO) throws Exception {
        return iAppVisitorPassCodeRecordService.getVisitorPassRecordPage(pageDTO);
    }
     /**
     * <desc>
     *      获取访客单信息
     * </desc>
     *
     * @param userId   用户编号
     * @param projectId   项目编号
     * @return
     * @author Qiang.S
     * @createDate 2019/05/05
     */
    @Override
    @RequestMapping(path = "/app/visitor/getReservationVisitorInfo",method = RequestMethod.POST)
    public List<MiniGetReservationProofPageVO> getReservationVisitorInfo(@RequestParam("userId")String userId, @RequestParam("projectId")String projectId) throws Exception {
        return iAppVisitorPassCodeRecordService.getReservationVisitorInfo(userId,projectId);
    }

    /**
     * <desc>
     *      获取当前用户注册人脸信息
     * </desc>
     *
     * @param userId   用户编号
     * @param projectId   项目编号
     * @param type   当前用户身份类型 1代表业主 2代表访客
     * @return 人脸url
     * @author Juguang.S
     * @createDate 2019/05/06
     */
    @Override
    @RequestMapping(path = "/app/visitor/getUserFaceUrlInfo",method = RequestMethod.POST)
    public Map<String,String> getUserFaceUrlInfo(@RequestParam("userId")String userId, @RequestParam("projectId")String projectId, @RequestParam("type")String type) {
        return iAppVisitorPassCodeRecordService.getUserFaceUrlInfo(userId,projectId,type);
    }

    /**
     * <desc>
     *      校验该访客记录是否已被物业审批并且已认证过
     * </desc>
     *
     * @param passId  访客单号
     * @return
     * @author Juguang.S
     * @createDate 2019/05/27
     */
    @Override
    @RequestMapping(path = "/app/visitor/isAllowedAuthenticate",method = RequestMethod.POST)
    public Integer isAllowedAuthenticate(@RequestParam("passId")String passId) {
        return iAppVisitorPassCodeRecordService.isAllowedAuthenticate(passId);
    }

    /**
     * <desc>
     *      获取有效的访客通行密码记录
     * </desc>
     *
     * @param projectId 项目编号
     * @param pageNo 页数
     * @param pageSize 每页数
     * @param userId 用户id
     * @return 有效的访客通行密码记录
     * @author wangzhi
     * @createDate 2019/07/11
     */
    @Override
    @RequestMapping(path = "/app/visitor/getAvailableVisitorPwd",method = RequestMethod.POST)
    public Map<String, Object> getAvailableVisitorPwd(@RequestParam("projectId") String projectId, @RequestParam("pageNo") String pageNo,
                                                      @RequestParam("pageSize") String pageSize, @RequestParam("userId") String userId) throws Exception {
        return iAppVisitorPassCodeRecordService.getAvailableVisitorPwd(projectId, pageNo, pageSize, userId);
    }

    /**
     * <desc>
     *      物业业主审核通过有效时间变更后重新处理生成二维码相关逻辑
     * </desc>
     *
     * @param appGetVisitPassWordDTO 访客密码通行记录实体类
     * @return
     * @author Juguang.S
     * @createDate 2020/09/16
     */
    @Override
    @RequestMapping(path = "/app/visitor/updateQrcodeByTimeModify",method = RequestMethod.POST)
    public AppVisitorPassCodeRecordPO updateQrcodeByTimeModify(@RequestBody AppGetVisitPassWordDTO appGetVisitPassWordDTO) throws Exception{
        return iAppVisitorPassCodeRecordService.updateQrcodeByTimeModify(appGetVisitPassWordDTO);
    }

}
